package com.example.mobile20339zwl0330;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView textView;
    private EditText yonghuming;
    private EditText mima;
    private Button denglu;
    private Button tuichu;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initView();//获取控件ID


        denglu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String yonghuming1 = yonghuming.getText().toString();
                String mima1 = mima.getText().toString();

                //输入不完整判断
                if (yonghuming1.equals("")){
                    Log.i("完整","用户名没输入");
                }

                else {
                    if (mima1.equals("")){
                        Log.i(("完整"),"密码未输入");
                    }

                }

                //判断
                if (yonghuming1.equals("admin")&mima1.equals("123456")){
                    Log.i("登录","登录成功");}
                else {
                    Log.i("登录","登录失败");

                }



            }
        }

        );
    }


    private void initView() {
        textView = findViewById(R.id.textView);
        yonghuming = findViewById(R.id.yonghuming);
        mima = findViewById(R.id.mima);
        denglu = findViewById(R.id.denglu);
        tuichu = findViewById(R.id.tuichu);


    }
}